home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.0 KB | 74 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import java.awt.event.*;
- import java.io.*;
-
- import quicktime.*;
- import quicktime.util.*;
- import quicktime.app.QTFactory;
- import quicktime.app.display.*;
- import quicktime.app.image.*;
- import quicktime.qd.*;
-
- /*
- This demo shows a simple slide show presentation where the SlideShow object defines
- the behaviour that moves the currently viewed image to the next or previous image
- based on mousePressed events.
- */
- public class ViewerDemo extends Frame {
- public static void main (String[] args) {
- ViewerDemo vd = new ViewerDemo();
- vd.init();
- vd.show();
- vd.toFront();
- }
- //____________________ INSTANCE METHODS
-
- public void init () {
- // The frame, canvas and viewer are all the same size
- try {
- QTSession.open();
-
- // add canvas to frame
- setLayout (new BorderLayout());
- QTCanvas canv = new QTCanvas ();
- add ("Center", canv);
-
- // create image sequence
- File file = QTFactory.findAbsolutePath ("images/Ship01.pct");
- ImageDataSequence seq = ImageUtil.createSequence (file);
- ImageSequencer images = new ImageSequencer (seq);
- images.setLooping (ImageSequencer.kLoopForwards);
-
- // create our SlideShow
- SlideShow viewer = new SlideShow (images);
-
- addNotify(); //required so we can set the frame to the right size for insets
- Insets insets = getInsets();
- Dimension d = new Dimension (viewer.getDisplayBounds().getWidth(), viewer.getDisplayBounds().getHeight());
- setSize ((insets.left + insets.right + d.width), (insets.top + insets.bottom + d.height));
-
- addWindowListener(new WindowAdapter () {
- public void windowClosing (WindowEvent e) {
- QTSession.close();
- dispose();
- }
- public void windowClosed (WindowEvent e) {
- System.exit(0);
- }
- });
- canv.setClient (viewer, true);
- } catch (Exception e) {
- e.printStackTrace();
- QTSession.close();
- }
- }
- }
-
-